package com.huluobo.high3demo.mine;

import androidx.lifecycle.MutableLiveData;

import com.huluobo.mvvm.db.eneity.UserInfo;
import com.huluobo.mvvm.model.BaseRepo;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by LC on 2023/9/22.
 */
public class MineRepo extends BaseRepo {

    public void queryUserInfo(String username, MutableLiveData<UserInfo> success, MutableLiveData<String> failed) {
        userInfoDao.queryUserInfo(username).subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<UserInfo>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(UserInfo userInfo) {
                        success.setValue(userInfo);
                    }

                    @Override
                    public void onError(Throwable e) {
                        failed.setValue(e.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
